package com.example.springboot.ytest.geek;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
* @author luffy
* @date 2021/4/4 23:12
**/
class OkHttpTest {
    OkHttpClient client = new OkHttpClient();

    String run(String url) throws IOException {
        Request request = new Request.Builder()
                .url(url)
                .build();

        try (Response response = client.newCall(request).execute()) {
            return response.body().string();
        }
    }

    public static void main(String[] args) {
        OkHttpTest okHttp = new OkHttpTest();
        try {
            String re = okHttp.run("http://localhost:8801");
            System.out.println(re);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}